<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
  <link href="//gmpg.org/xfn/11" rel="profile">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="generator" content="Hugo 0.69.0" />

  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>我的博客</title>

  
  <link type="text/css" rel="stylesheet" href="/hugoblog/css/print.css" media="print">
  <link type="text/css" rel="stylesheet" href="/hugoblog/css/poole.css">
  <link type="text/css" rel="stylesheet" href="/hugoblog/css/syntax.css">
  <link type="text/css" rel="stylesheet" href="/hugoblog/css/hyde.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Abril+Fatface|PT+Sans:400,400i,700">


  
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144-precomposed.png">
  <link rel="shortcut icon" href="/favicon.png">

  
  <link href="/hugoblog/index.xml" rel="alternate" type="application/rss+xml" title="我的博客" />
  
</head>

  <body class="theme-base-0self ">
  <aside class="sidebar">
  <div class="container sidebar-sticky">
    <div class="sidebar-about">
      <a href="/hugoblog/"><h1>我的博客</h1></a>
      <p class="lead">
       这里是骆建宇的个人博客 
      </p>
    </div>

    <nav>
      <ul class="sidebar-nav">
        <li><a href="/hugoblog/">Home</a> </li>
        
      </ul>
    </nav>

    <p>&copy; 2020. All rights reserved. </p>
  </div>
</aside>

    <main class="content container">
    <div class="posts">
<article class="post">
  <h1 class="post-title">
    <a href="/hugoblog/day05/">Django和redis</a>
  </h1>
  <time datetime="2020-04-26T15:46:05&#43;0800" class="post-date">Sun, Apr 26, 2020</time>
  #### 1.django简易登录
#登录接口 class Login(APIView): def get(self,request): # 接收参数 username =request.GET.get('username',None) password =request.GET.get('password',None) # 查询数据:.get user = User.objects.filter(username=username,password=make_password(password)).first() if user: return Response({'code':200,'message':'登录成功','uid':user.id,'username':user.username}) else: return Response({'code':403,'message':'你的用户名或密码错误'}) #### 2.redis连接
# 导包 import redis # 定义ip和端口 host = &quot;localhost&quot; port = 6379 # 建立链接 r = redis.Redis(host=host,port=port) # 赋值 r.set('test','test') # 取值 code = r.get('test') # 转码 code =code.decode(&quot;utf-8&quot;) print(code) #### 3.django验证码
# 自定义图片验证码 class MyCode(View): # 定义rgb随机颜色 def get_random_color(self): R = random.randrange(255) G = random.
  
  <div class="read-more-link">
    <a href="/hugoblog/day05/">Read More…</a>
  </div>
  
</article><article class="post">
  <h1 class="post-title">
    <a href="/hugoblog/day04/">Django</a>
  </h1>
  <time datetime="2020-04-26T15:45:57&#43;0800" class="post-date">Sun, Apr 26, 2020</time>
  ## Django创建项目、数据库迁移、用户注册 #### 1.创建django项目
django-admin startproject 项目名#### 2.创建项目的app
cd 项目名python manage.py startapp my_app#### 3.数据库迁移
python manage.py makemigrationspython manage.py migrate#### 4.启动django项目
python manage.py runserver#### 5.简易的用户注册
# 注册接口class Register(APIView):def get(self,request):# 接收参数username =request.GET.get('username',None)password =request.GET.get('password',None)# 排重操作user = User.objects.filter(username=username).first()if user:return Response({'code':403,'message':'该用户名已存在'})# 入库user =User(username=username,password=make_password(password))# 保存结果user.save()return Response({'code':200,'message':'恭喜注册成功'})#### 6.md5加密
import hashlib# md5加密方法def make_password(mypass):# 生成md5对象md5 =hashlib.
  
  <div class="read-more-link">
    <a href="/hugoblog/day04/">Read More…</a>
  </div>
  
</article><article class="post">
  <h1 class="post-title">
    <a href="/hugoblog/day03/">Django操作</a>
  </h1>
  <time datetime="2020-04-23T12:14:52&#43;0800" class="post-date">Thu, Apr 23, 2020</time>
  导包 from django.shortcuts import render,redirect #导包 from django.http import HttpResponse,HttpResponseRedirect,JsonResponse #导入类视图 from django.views import View #from myapp.models import User import json from django.core.serializers import serialize from rest_framework.response import Response from rest_framework.views import APIView #导入加密库 import hashlib #导入图片库 #绘画库 from PIL import ImageDraw #字体库 from PIL import ImageFont #图片库 from PIL import Image #随机库 import random #文件流 import io import requests #导入上传文件夹配置 from mydjango.settings import UPLOAD_ROOT import os #导入原生sql模块 from django.db import connection import jwt #导入redis数据库 import redis #导入时间模块 import time #导入公共目录变量 from mydjango.
  
  <div class="read-more-link">
    <a href="/hugoblog/day03/">Read More…</a>
  </div>
  
</article><article class="post">
  <h1 class="post-title">
    <a href="/hugoblog/day02/">Vue</a>
  </h1>
  <time datetime="2020-04-22T10:56:08&#43;0800" class="post-date">Wed, Apr 22, 2020</time>
  vue基础命令 定义网页的骨架 &lt;template&gt; &lt;div&gt; &lt;/div&gt; &lt;/template&gt; &lt;style scoped&gt; .on {background: rebeccapurple;color: white} .off {background: red;color: black} background 背景颜色 color 字体颜色 &lt;/style&gt; 定义网页样式 定义网页的行为 &lt;scrapy&gt; export default { //定义数据  data(){ return{ msg:&#39;&lt;h1&gt;这是一个变量&lt;/h1&gt;&#39;, } }, //钩子方法  mounted:function () { }, //计算属性  computed:{ }, //监听属性  watch:{ counter:function (nval,oval) { console.log(&#39;计数器由&#39;+oval+&#39;变换为新的&#39;+nval) } }, //自定义方法  methods:{ }, &lt;/scrapy&gt; 语法 &lt;div v-html=&#34;msg&#34;&gt;&lt;/div&gt; 以html语法展示 {{ msg }} 普通战展示 &lt;div v-show=&#34;&#34;&gt;&lt;/div&gt; 简单的判断,展示出正确的数据,错误的不展示 &lt;div v-if=&#34;type === &#39;A&#39;&#34;&gt;A&lt;/div&gt; &lt;div v-else-if=&#34;type === &#39;B&#39;&#34;&gt;B&lt;/div&gt; &lt;div v-else&gt; 也是判断,比v-show多一点功能 &lt;ul&gt; &lt;li v-for=&#34;(item,index) in tlist&#34; :class=&#34;{on:index%2==0,off:index%2!
  
  <div class="read-more-link">
    <a href="/hugoblog/day02/">Read More…</a>
  </div>
  
</article><article class="post">
  <h1 class="post-title">
    <a href="/hugoblog/day01/">git与hugo相关命令</a>
  </h1>
  <time datetime="2020-04-21T09:30:10&#43;0800" class="post-date">Tue, Apr 21, 2020</time>
  git 相关命令 创建文件夹 mkdir teacher
复制代码到文件夹 git clone 网址
从远程仓库拉去最新版本代码 git pull origin master
清掉配置 git config --system --unset credential.helper 
回退git 线下 1.git log 2.git reset --hard commit里的东西 线上 1.git push origin HEAD --force 创建项目 git全局设置 (1).git config --global user.name &quot;骆建宇&quot; (2).git config --global user.email &quot;1439627999@qq.com&quot; 创建git仓库 (1).mkdir 文件名(项目名) (2).cd 文件名(项目名) (3).git init 创建.git (4).复制项目 (5).git add -A 添加本地的暂存区 (6).git commit -m '初始化项目' (7).创建git仓库第七条:git remote add origin https://gitee.com/luo_jian_yu/mydjango123.git (8).创建git仓库第八条:git push -u origin master 每天的素质三连击 1.
  
  <div class="read-more-link">
    <a href="/hugoblog/day01/">Read More…</a>
  </div>
  
</article>
</div>
    </main>

    
  </body>
</html>
